//
//  findPasswordSucceedViewController.m
//  忘不了
//
//  Created by rimi on 16/7/10.
//  Copyright © 2016年 handuan. All rights reserved.
//

#import "findPasswordSucceedViewController.h"
#import "SDAutoLayout.h"
#import "HYScratchCardView.h"

@interface findPasswordSucceedViewController ()
@property (nonatomic, strong) HYScratchCardView *scratchCardView;//涂层背景view
@end

@implementation findPasswordSucceedViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60)
                                                         forBarMetrics:UIBarMetricsDefault];//隐藏导航栏返回按钮自带的文字
    self.title = @"找回密码成功";
    //设置导航栏标题颜色、字体大小等
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20],NSForegroundColorAttributeName:[UIColor brownColor]}];
    
    UIImageView *backGroudView = [[UIImageView alloc]initWithFrame:self.view.frame];
    backGroudView.image = [UIImage imageNamed:@"s.jpg"];
    [self.view addSubview:backGroudView];
    
    [self initInterface];
    
}

- (void)initInterface {
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetHeight(self.view.bounds) * 0.3, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds) * 0.1)];
    label.text = @"刮开下方图码显示密码";
    label.textAlignment = NSTextAlignmentCenter;
    label.textColor = [UIColor redColor];
    [self.view addSubview:label];
    self.scratchCardView = [[HYScratchCardView alloc]initWithFrame:CGRectMake(self.view.frame.size.width*0.2,self.view.frame.size.height*0.45, self.view.frame.size.width*0.6, self.view.frame.size.height*0.1)];
    self.scratchCardView.image = [UIImage imageNamed:@"findPasswordBack"];
    [self.view addSubview:self.scratchCardView];
    
    self.scratchCardView.completion = ^(id userInfo) {
        _passwordLabel = [[UILabel alloc]init];
        _passwordLabel.text= [NSString stringWithFormat:@"您的密码是:%@",self.password];
        _passwordLabel.backgroundColor = [UIColor clearColor];
        _passwordLabel.textAlignment = NSTextAlignmentCenter;
        _passwordLabel.textColor = [UIColor redColor];
        _passwordLabel.font = [UIFont systemFontOfSize:18];
        [self.view addSubview:_passwordLabel];
        _passwordLabel.sd_layout
        .leftSpaceToView(self.view,self.view.frame.size.width*0.2)
        .rightSpaceToView(self.view,self.view.frame.size.width*0.2)
        .topSpaceToView(self.view,self.view.frame.size.height*0.45)
        .heightIs(self.view.frame.size.height*0.1);
    };
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.scratchCardView reset];//涂层复原
}

@end
